package com.machine.filling.util;


import java.util.UUID;

public class Common {


    /**
     * 权限申请 存储
     */
    public static final int PERMIASSION_REQ_STORGE = 10001;
    /**
     * 倒计时时间  提示插卡界面  支付结果界面返回主界面倒计时
     */
    public static long BACK_TIME = 60;//返回主界面的倒计时s

    /**
     * 是否开启log日志
     */
    public static final boolean openlog = true;

    /**
     * IP地址（http）
     */
    public static final String HTTP_BASE_URL = "http://www.jiayoubacn.com";
    /**
     * API 通用接口
     */
    public static final String HTTP_BASE_URL_API = HTTP_BASE_URL + "/client-api-server/api";

    /**
     * websocket 的请求地址  还需加上  WS_URL_ + token + machineId
     */
    public static final String WS_URL_ = "ws://www.jiayoubacn.com/client-ws-server/ws/";

    /**
     * 登录
     */
    public static final String HTTP_LOGIN = "/client-api-server/init/login";

    /**
     * 油站信息
     */
    public static final String HTTP_OIL_STATION_INFO = "/client-api-server/init/seller";

    /**
     * 绑定终端机和油机
     */
    public static final String HTTP_BIND_CLIENT_AND_OIL_MACHINE = "/client-api-server/init/bindMachine";

    /**
     * 解绑终端机与油机 还原系统设置
     */
    public static final String HTTP_UNBIND_CLIENT_AND_OIL_MACHINE = "/client-api-server/init/initClient";

    /**
     * 油机列表
     */
    public static final String HTTP_OIL_MACHINE_LIST = "/client-api-server/init/machines";

    /**
     * 油品列表
     */
    public static final String HTTP_OIL_TYPE_LIST = "/client-api-server/init/types";

    /**
     * 油罐列表
     */
    public static final String HTTP_OIL_TANK_LIST = "/client-api-server/init/pots";

    /**
     * 油枪列表
     */
    public static final String HTTP_OIL_GUN_LIST = "/client-api-server/init/guns";

    /**
     * 油枪详情
     */
    public static final String HTTP_OIL_GUN_DETAIL = "/client-api-server/init/gunDetail";

    /**
     * 添加油枪信息
     */
    public static final String HTTP_ADD_OIL_GUN_INFO = "/client-api-server/init/add";

    /**
     * 修改油枪信息
     */
    public static final String HTTP_MODIFY_OIL_GUN_INFO = "/client-api-server/init/edit";
    /**
     * 删除油枪
     */
    public static final String HTTP_DEL_OIL_GUN = "/client-api-server/init/delGun";

    /**
     * 初始化终端完毕，调用获取token令牌，进入主界面
     */
    public static final String HTTP_GET_TOKEN = "/client-api-server/init/in";

    /**
     * 查询订单列表时的登录接口
     */
    public static final String HTTP_FILLER_LOGIN = "/client-api-server/init/fillerLogin";


//-------------- websocket--------------------------------------
    /**
     * 建立websocket  (action)
     */
    public static final String ACT_CREATE_0001 = "0001";
    /**
     * 获取首页油枪信息
     */
    public static final String ACT_GET_GUNS_INFO_1000 = "1000";
    /**
     * 获取油卡信息
     */
    public static final String ACT_GET_CARD_INFO_1001 = "1001";
    /**
     * 预约订单信息
     */
    public static final String ACT_GET_PRE_ORDER_INFO_1002 = "1002";
    /**
     * 更新油枪状态
     */
    public static final String ACT_UPDATE_GUN_STATE_1003 = "1003";
    /**
     * 检测版本更新
     */
    public static final String ACT_CHECK_VERSION_1004 = "1004";
    /**
     * 创建订单
     */
    public static final String ACT_CREATE_NEW_ORDER_1005 = "1005";
    /**
     * 创建预约订单
     */
    public static final String ACT_CREATE_PRE_ORDER_1009 = "1009";
    /**
     * 获取油卡加油的订单
     */
    public static final String ACT_GET_CARD_FUELING_ORDER_1010 = "1010";
    /**
     * 现金支付
     */
    public static final String ACT_PAY_CASH_1011 = "1011";
    /**
     * 油卡支付
     */
    public static final String ACT_PAY_CARD_1012 = "1012";
    /**
     * 获取广告列表
     */
    public static final String ACT_GET_AD_LIST_1013 = "1013";
    /**
     * 解锁预约订单
     */
    public static final String ACT_UNLOCK_PRE_ORDER_1014 = "1014";
    /**
     * 锁枪
     */
    public static final String ACT_LOCK_GUN_1007 = "1007";
    /**
     * 开枪
     */
    public static final String ACT_UNLOCK_GUN_1008 = "1008";

    /**
     * 自助模式
     */
    public static final String ACT_SELF_1016 = "1016";
    /**
     * 非自助模式
     */
    public static final String ACT_UNSELF_1017 = "1017";
    /**
     * 更新工作模式 自助 非自助
     */
    public static final String ACT_UPDATE_WORK_MODE_1018 = "1018";


    /**
     * 获取支付支付宝二维码
     */
    public static final String ACT_GET_WX_ERWEIMA_1015 = "1015";
    /**
     * 获取微信二维码
     */
    public static final String ACT_GET_ZFB_ERWEIMA_1006 = "1006";

    /**
     * 查询支付状态
     */
    public static final String ACT_GET_ERWEIMA_1010 = "1010";

    /**
     * 油机状态  状态 1空闲 2插卡中 3抬枪 4加油中 5挂抢 6结算中 7锁枪 ( 没哟 开枪中 9锁枪中)
     */
    //空闲
    public static final String OIL_STATE_FREE = "1";
    //插卡中
    public static final String OIL_STATE_CARD_IN = "2"; //授權有卡
    //抬枪
    public static final String OIL_STATE_GUN_UP = "3";//无
    //加油中
    public static final String OIL_STATE_FUELING = "4";
    //挂枪
    public static final String OIL_STATE_GUN_DOWN = "5";//无
    //结算中
    public static final String OIL_STATE_BILLING = "6";//加油结束之后,支付之前
    //锁枪
    public static final String OIL_STATE_LOCK = "7";
    //开抢中
    public static final String OIL_STATE_UNLOCKING = "8";
    //锁枪中
    public static final String OIL_STATE_LOCKING = "9";


    /**
     * 离线
     */
    public static final String OIL_STATE_OFFLINE = "10";

    //加油结束
//	public static final String OIL_STATE_FUEL_END = "2101";
    //授权有卡
//	public static final String OIL_STAT_AUTHORIZE_CARD = "0x02";
    /**
     * 加油前的准备
     */
    public static final String OIL_STAT_PREPARE = "8101";


    /**
     * 生成订单编号
     *
     * @return
     */
    public static String createOrderNum() {
        int hashCodeV = UUID.randomUUID().toString().hashCode();
        if (hashCodeV < 0) {//有可能是负数
            hashCodeV = -hashCodeV;
        }
        // 0 代表前面补充0
        // 10 代表长度为10
        // d 代表参数为正数型
        String endStr = String.format("%010d", hashCodeV);
        String startStr = String.valueOf((int) ((Math.random() * 9 + 1) * 10000));
        return startStr + endStr;
    }
//-----------------------------------------------


    /**
     * 油站名称
     */
    public static final String EXTRA_STATION_NAME = "station_name";
    /**
     * 油站编号
     */
    public static final String EXTRA_STATION_NUM = "station_num";
    /**
     * 油站地址
     */
    public static final String EXTRA_STATION_ADDR = "station_addr";


    /**
     * 订单状态  未支付
     */
    public static final String ORDER_UNPAY = "1";
    /**
     * 已支付
     */
    public static final String ORDER_PAYED = "3";
    /**
     * 已支付未写卡
     */
    public static final String ORDER_UNWRITE = "2";

    /**
     * 订单已提交  0 未上传 1已上传
     */
    public static final String ORDER_UPLOADSTATE_YES = "1";
    /**
     * 订单未提交
     */
    public static final String ORDER_UPLOADSTATE_NO = "0";

    /**
     * 预约 1预约 0未预约 2全部
     */
    public static final String ORDER_TYPE_ORDERED = "1";
    /**
     * 未预约
     */
    public static final String ORDER_TYPE_NOORDERED = "0";

    //1支付宝 2微信 3现金 4油卡
    public static final String PAY_MODE_ZHIFUBAO = "1";
    public static final String PAY_MODE_WEIXIN = "2";
    public static final String PAY_MODE_CASH = "3";
    public static final String PAY_MODE_CARD = "4";
    public static final String PAY_MODE_ORDER = "5";

    //订单查询条件
    public static final String ORDER_TYPE_ALL = "2";//查询所有 包含预约和正常加油

    public static final String MACHINE_VERSION = "10";//查询所有 包含预约和正常加油

    //提交订单时候,需要传入此字段 标明,此订单是否是异常订单的提交
    public static final String COMMIT_ORDER_NORMAL = "1";//1正常订单 2异常订单
    public static final String COMMIT_ORDER_EXCEPTION = "2";//1正常订单 2异常订单

    /************************************************************/

    public static final boolean IS_EXCETPION_ORDER_USE = true;//是否启用 异常订单处理;(意思是,数据库中的TempOrderModle 被ExceptionOrderModle 所取代)

}
